/**
 * 
 */
package com.itinsys.enma.manager.impl;

import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;

import com.itinsys.enma.domain.dto.CareerYearDTO;
import com.itinsys.enma.domain.dto.SubjectDTO;
import com.itinsys.enma.domain.response.SubjectResponse;
import com.itinsys.enma.manager.UCUDataManager;
import com.itinsys.enma.service.SingletonService;

/**
 * @author pferraz
 *
 */
public class UCUDataManagerImpl implements UCUDataManager {

	@Autowired
	private SingletonService singletonService;
	
	/**
	 * 
	 */
	public UCUDataManagerImpl() {
		// TODO Auto-generated constructor stub
	}
	

	/***
	 * Encargado de proporcionar las materias de la base de datos
	 */
	public SubjectResponse getSubjectsByCareerAndYear(String career,String year) {
		SubjectResponse subResponse=new SubjectResponse();
		subResponse.setSubjects(singletonService.getSubjectsByYearByCareer().get(career).get(year));
		
		return subResponse;
		
		
		
	}


	@Override
	public CareerYearDTO getCareerAndYear() {
		
		return new CareerYearDTO(new ArrayList<String>(singletonService.getSubjectsByYearByCareer().keySet()),singletonService.getMaxYear());
		
	}


	@Override
	public boolean subjectExistByCareerAndYear(String career,String careerYear, String subject) {
		return getSubjectsByCareerAndYear(career,careerYear).getSubjects().contains(new SubjectDTO(subject));
	}

	
}
